package com.zck.aiagent.rag;

import jakarta.annotation.Resource;
import org.springframework.ai.embedding.EmbeddingModel;
import org.springframework.ai.vectorstore.SimpleVectorStore;
import org.springframework.ai.vectorstore.VectorStore;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class LoveAppVectorStoreConfig {

    @Resource
    private LoveAppDocumentLoader loveAppDocumentLoader;

    @Bean
    public VectorStore loveAppVectorStores(EmbeddingModel dashScopeEmbeddingModel) throws IOException {
        SimpleVectorStore simpleVectorStore = SimpleVectorStore.builder(dashScopeEmbeddingModel)
                .build();
        //加载文档
        simpleVectorStore.doAdd(loveAppDocumentLoader.loadMarkdowns());
        return simpleVectorStore;
    }

    @Bean
    public VectorStore loveAppVectorStore(EmbeddingModel dashScopeEmbeddingModel) throws IOException {
        SimpleVectorStore simpleVectorStore = SimpleVectorStore.builder(dashScopeEmbeddingModel)
                .build();
        //加载文档
        simpleVectorStore.doAdd(loveAppDocumentLoader.loadMarkdown());
        return simpleVectorStore;
    }
}
